/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

/**
 *
 * @author Andy
 */
@Entity(name = "Reservation")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class ReservationEntity extends DataObjectEntity implements Serializable {

    @ManyToOne
    private CompletedGoodsEntity product;
    //maps one reservation to one product type
    @ManyToOne
    private SalesOrderEntity salesOrder;
    //maps one reservation to one sales order
    @OneToOne(cascade=CascadeType.ALL)
    private PickingOrderEntity pickingOrder;
 
    private int quantity = 0;
    private boolean planned;

    public ReservationEntity() {
        super();
        //product = new ProductEntity();
        //salesOrder = new SalesOrderEntity();
        pickingOrder = new PickingOrderEntity();
    }

    public boolean isPlanned() {
        return planned;
    }

    public void setPlanned(boolean planned) {
        this.planned = planned;
    }


    public PickingOrderEntity getPickingOrder() {
        return pickingOrder;
    }

    public void setPickingOrder(PickingOrderEntity pickingOrder) {
        this.pickingOrder = pickingOrder;
    }

    public CompletedGoodsEntity getProduct() {
        return product;
    }

    public void setProduct(CompletedGoodsEntity product) {
        this.product = product;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public SalesOrderEntity getSalesOrder() {
        return salesOrder;
    }

    public void setSalesOrder(SalesOrderEntity salesOrder) {
        this.salesOrder = salesOrder;
    }

    @Override
    public String childToString() {
        String res = "ReservationEntity{" + "product=" + product + ", salesOrder=" + salesOrder + ", pickingOrder=" + pickingOrder + ", quantity=" + quantity + '}';
        if (this instanceof PlannedReserveEntity) {
            res += "\n" + ((PlannedReserveEntity) this).rootToString();
        }
        return res;
    }
}
